import request from '@/utils/request'
import type { TrademarkResponseData, recordsDataType } from '@/api/product/type'
enum API {
  TRADEMARK_URL = '/admin/product/baseTrademark/',
  ADDTRADEMARK_URL = '/admin/product/baseTrademark/save',
  UPDATETRADEMARK_URL = '/admin/product/baseTrademark/update',
  DELETTRADEMARK_URL = '/admin/product/baseTrademark/remove',
}
//请求获取品牌数据
export const reqTradeMark = (page: number, limit: number) =>
  request.get<any, TrademarkResponseData>(
    API.TRADEMARK_URL + `${page}/${limit}`,
  )

//添加或修改品牌
export const addOrUpdateTrademark = (data: recordsDataType) => {
  //如果有id  说明是修改
  if (data.id) {
    return request.put<any, any>(API.UPDATETRADEMARK_URL, data)
  }
  //如果无id，说明是新增
  else {
    return request.post<any, any>(API.ADDTRADEMARK_URL, data)
  }
}

//删除品牌
export const reqDeleteTrademark = (id: number) =>
  request.delete<any, any>(API.DELETTRADEMARK_URL + '/' + id)
